package com.woniuxy.admin.controller;


import com.woniuxy.admin.entity.ScoreDiscount;
import com.woniuxy.admin.entity.ScoreIncrease;
import com.woniuxy.admin.mapper.ScoreIncreaseMapper;
import com.woniuxy.admin.service.AdminInfoService;
import com.woniuxy.admin.service.ScoreIncreaseService;
import com.woniuxy.admin.util.JWTUtil;
import com.woniuxy.admin.util.TokenUtil;
import com.woniuxy.core.annotation.Permission;
import com.woniuxy.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ...
 * @since 2024年05月22日
 */
@RestController
@RequestMapping("/scoreIncrease")
@Api(tags="积分增加规则")
public class ScoreIncreaseController {

    @Resource
    private ScoreIncreaseService scoreIncreaseService;


    @Resource
    private TokenUtil tokenUtil;
    /**
     * 查询积分增加规则
     * @return
     */
    @GetMapping("/selectScoreIncrease")
    @ApiOperation("查询积分增加规则")
    public Result selectScoreIncrease(){
        ScoreIncrease scoreIncrease = scoreIncreaseService.getById(1);
        return Result.success("查询积分增加规则成功",scoreIncrease);
    }

    /**
     * 修改积分增加规则
     * @param increaseRatio 增加比例1元钱 增加多少积分
     * @param token
     * @return
     */
    @GetMapping("/updateScoreIncrease")
    @ApiOperation("修改积分增加规则")
    @Permission(roles = {"超级管理员"})
    @ApiImplicitParam(name="increaseRatio",value = "增加规则")
    public Result updateScoreIncrease(BigDecimal increaseRatio, @RequestHeader String token){
        Integer accountId = tokenUtil.getAccountId(token);
        scoreIncreaseService.updateScoreIncrease(increaseRatio,accountId);
        return Result.success("修改积分增加规则成功",null);
    }
}

